package top.tomxwd;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import top.tomxwd.common.Result;
import top.tomxwd.entity.Payment;

/**
 * @author xieweidu
 * @createDate 2020-07-15 22:02
 */
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderZkController {

    public static final String INVOKE_URL = "http://payment-8004";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/payment/getById/{id}")
    public Result<Payment> create(@PathVariable("id") Long id){
        ResponseEntity<Result<Payment>> responseEntity = restTemplate.exchange(INVOKE_URL + "/payment/getById/"+id, HttpMethod.GET, null, new ParameterizedTypeReference<Result<Payment>>() {
        });
        return responseEntity.getBody();
    }

}
